<!--
 * @Descripttion: 
 * @LastEditors: xzh
 * @LastEditTime: 2023-09-21 20:47:48
-->
<template>
  <!-- 关联属性表格 -->
  <DileTable>
    <template #preColumn>
      <vxe-column
        v-for="(column, index) in ProductRelAttrUtils.relAttrColumn[relAttr]"
        :key="column.field"
        :title="$t(column.title)"
      >
        <template #default="{ row }">
          <span v-if="column.edit == false">{{ row[column.field] }}</span>
          <el-input v-else v-model="row[column.field]" size="default" />
        </template>
      </vxe-column>
    </template>
  </DileTable>
</template>

<script setup lang="ts">
import { ref, reactive, provide, onMounted } from "vue";
import type { object_Inf } from "@/utils/typings/index.type";
import { propsParam_Inf } from "@/components/dile-table/index.type";
import { useI18n } from "vue-i18n";
import ProductRelAttrUtils from "./utils";
const emit = defineEmits([]);
const props = defineProps({
  //关联属性
  relAttr: {
    type: String,
    requited: true,
    default: "",
  },
});
let { t } = useI18n();
/**
 * @Author: xzh
 * @Descripttion: 初始化
 * @Param:
 */
onMounted(() => {
  initTableData();
});
/**
 * @Author: xzh
 * @Descripttion:加载表格数据
 * @Param:
 * @param {*} dataArr
 */
let initTableData = () => {
  let { relAttr } = props;
  let tableData = ProductRelAttrUtils.relAttrFixRow[relAttr].map(
    (x: object_Inf) => {
      let { value, label } = x;
      return {
        [relAttr == ProductRelAttrUtils.relAttrMap.productAttr
          ? "name"
          : "processName"]: t(label),
      };
    }
  );
  Object.assign(propsParam, {
    tableData,
  });
};

/**
 * @Author: xzh
 * @Descripttion: 表格参数
 * @Param:
 */
let propsParam = reactive<propsParam_Inf>({
  loading: false,
  tableData: [],
  isPagination: false,
  bottomUp: true,
  maxHeight: 300,
  emitEvents: {},
});
provide("propsParam", propsParam);
</script>
<style lang="scss" scoped></style>
